package org.extreme.script.core.parser;

import org.extreme.script.CalculateContext;
import org.extreme.script.Primitive;



public class Exp implements Node {
	OrExp conditionalExpression;

	Exp(OrExp conditionalExpression) {
		this.conditionalExpression = conditionalExpression;
	}
	
	public Object eval(CalculateContext calculator) throws UtilEvalError {
		if(conditionalExpression == null) {
			throw new InterpreterError("conditionalExpression should not be null");
		}
		
		Object result = conditionalExpression.eval(calculator);
		
		if(result == null) {
			result = Primitive.NULL;
		}
		
		return result;
	}
	
	public void traversal4Tiny(TinyHunter hunter) {
		conditionalExpression.traversal4Tiny(hunter);
	}
	
	public String exString(CalculateContext calculator) {
		return conditionalExpression.exString(calculator);
	}
	
	public String toString() {
		return conditionalExpression.toString();
	}
	

	public String getExpression(int rowIndex, int rowChanged, int columnIndex, int colChanged, boolean isParameter) {
		return conditionalExpression.getExpression(rowIndex, rowChanged, columnIndex, colChanged, isParameter);
	}

	public String[] parserParameter() {
		return conditionalExpression.parserParameter();
	}
}
